package csc.fresher.finalgroupfour.domain;

import java.io.Serializable;
import java.util.Collection;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

@Entity
public class User implements Serializable {

	private static final long serialVersionUID = 1L;
	
	@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long userId;
	
	@Column(unique=true)
	private String loginId;
	
	private String password;
	private String userState;
	private int attemptedLogin;
	
	@ManyToOne
	@JoinColumn(name="role")
	private Role role;
	
	@OneToMany(mappedBy="user", fetch=FetchType.EAGER)
	private Collection<Account> accounts;
	
	/**
	 * Required Constructor
	 */
	public User() {}
	
	/**
	 * @param loginId
	 * @param password
	 * @param userState
	 * We can define as many as constructors that we want.
	 */
	public User(String loginId, String password, String userState) {
		this.loginId = loginId;
		this.password = password;
		this.userState = userState;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public String getLoginId() {
		return loginId;
	}

	public void setLoginId(String loginId) {
		this.loginId = loginId;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getUserState() {
		return userState;
	}

	public void setUserState(String userState) {
		this.userState = userState;
	}

	public int getAttemptedLogin() {
		return attemptedLogin;
	}

	public void setAttemptedLogin(int attemptedLogin) {
		this.attemptedLogin = attemptedLogin;
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}

	public Collection<Account> getAccounts() {
		return accounts;
	}

	public void setAccounts(Collection<Account> accounts) {
		this.accounts = accounts;
	}
	
}
